import {
    CallHandler,
    ExecutionContext,
    Injectable,
    NestInterceptor,
} from '@nestjs/common';
import { Observable, map } from 'rxjs';
import { ResponseJson } from '@/common/type/app.dto';

@Injectable()
export class YhResponseInterceptor<T> implements NestInterceptor {
    /* constructor(parameters) {} */

    intercept(
        context: ExecutionContext,
        next: CallHandler<any>,
    ): Observable<ResponseJson> | Promise<Observable<ResponseJson>> {
        return next.handle().pipe(
            map((data: ResponseJson) => {
                return data;
            }),
        );
    }
}
